<template>
	<view class="container">
		<view class="header">
			<view class="item">
				<text>{{num}}</text>
				<text>团队人数</text>
			</view>
			<view class="item">
				<text>{{todayCount}}</text>
				<text>今日推广收益</text>
			</view>
			<view class="item">
				<text>{{count}}</text>
				<text>获得黑贝壳总计</text>
			</view>
		</view>
		<view class="cut"></view>
		<view class="member">
			<scroll-view scroll-y="true" class="scroll-Y" @scrolltolower="lower">
				<view class="top"></view>
				<view class="item" v-for="(item,index) in list" :key="index">
					<view class="left">
						<image :src="item.avatar" mode=""></image>
						<view>
							<text>{{item.nickname}}</text>
							<text>{{item.create_time}}</text>
						</view>
					</view>
					<view class="right">
						<image src="../../../static/images/public/shellIcon.png" mode=""></image>
						<text>{{item.black_shell_num}}</text>
					</view>
				</view>
				<uni-load-more class="loadMore" iconType="circle" :status="loadStatus" :contentText="contentText"></uni-load-more>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue";
	import {
		teamList
	} from "@/api/user.js"
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				num: 0,
				todayCount: 0,
				count: 0,
				scrollTop: 0,
				page: 1,
				limit: 10,
				list: [],
				loadStatus: "loading",
				contentText: {
					contentdown: "上拉显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多了"
				},
				nodata: false
			};
		},
		onLoad(options) {
			this.getList()
		},
		methods: {
			getList() {
				teamList({
					page: this.page,
					limit: this.limit,
				}).then(res => {
					this.num = res.data.spreadCount
					this.count = res.data.shellShellCount
					this.todayCount = res.data.shellTodayShellCount
					this.loadStatus = "more";
					this.list.push.apply(this.list, res.data.userShellCountList);
					if (res.data.userShellCountList.length < this.limit) this.loadStatus = "noMore"; //判断所有数据是否加载完成；
					this.page = this.page + 1;
					if (this.list.length == 0) {
						this.nodata = true
						this.contentText.contentnomore = '暂无数据'
					} else {
						this.nodata = false
					}
				})
			},
			lower() {
				if (this.loadStatus == "more")
					(this.loadStatus = "loading"), this.getList();
			}
		}
	};
</script>

<style lang="scss" scoped>
	.container {
		.header {
			display: flex;
			justify-content: space-around;
			height: 180rpx;
			color: #fff;
			background-color: $theme-color;

			.item {
				display: flex;
				flex-direction: column;
				justify-content: center;
				text-align: center;

				text:nth-of-type(1) {
					font-size: 46rpx;
					font-weight: bold;
					color: rgba(255, 255, 255, 1);
				}

				text:nth-of-type(2) {
					margin-top: 10rpx;
					font-size: 24rpx;
					font-weight: 400;
					color: rgba(255, 255, 255, 1);
				}
			}
		}

		.cut {
			background-color: $theme-color;
			height: 50rpx;
		}

		.member {
			height: calc(100vh - 190rpx);
			padding: 0 60rpx;
			box-sizing: border-box;
			background-color: #fff;
			border-radius: 40rpx 40rpx 0px 0px;
			margin-top: -40rpx;

			.scroll-Y {
				height: 100%;

				.top {
					height: 40rpx;
				}
			}

			.item {
				display: flex;
				justify-content: space-between;
				height: 160rpx;
				border-bottom: 1rpx solid #eee;

				.left {
					display: flex;
					align-items: center;

					image {
						margin-right: 30rpx;
						width: 100rpx;
						height: 100rpx;
						border-radius: 50rpx;
						background-color: $theme-color;
					}

					view {
						display: flex;
						flex-direction: column;
						justify-content: space-between;

						text:nth-of-type(1) {
							font-size: 28rpx;
							font-weight: 400;
							color: rgba(51, 51, 51, 1);
						}

						text:nth-of-type(2) {
							margin-top: 10rpx;
							font-size: 22rpx;
							font-weight: 400;
							color: rgba(153, 153, 153, 1);
						}
					}
				}

				.right {
					display: flex;
					align-items: center;

					image {
						width: 30rpx;
						height: 21rpx;
						margin-right: 10rpx;
					}

					text {
						font-size: 30rpx;
						font-weight: bold;
						color: rgba(51, 51, 51, 1);
					}
				}
			}
		}
	}
</style>
